<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>layuiAdmin 主页示例模板二</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="/static/admin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="/static/admin/style/admin.css" media="all">
</head>
<body>

<div class="layui-fluid">
  <div class="layui-row layui-col-space15">

    <div class="layui-col-sm6 layui-col-md2">
      <div class="layui-card">
        <div class="layui-card-header">
          题库题目数量
          <span class="layui-badge layui-bg-blue layuiadmin-badge">题库</span>
        </div>
        <div class="layui-card-body layuiadmin-card-list">
          <p class="layuiadmin-big-font">{$question_count}</p>
          <p>
            考试
            <span class="layuiadmin-span-color"> <i
                    class="layui-inline layui-icon layui-icon-flag"></i></span>
          </p>
        </div>
      </div>
    </div>
    <div class="layui-col-sm6 layui-col-md2">
      <div class="layui-card">
        <div class="layui-card-header">
          考试试卷数量
          <span class="layui-badge layui-bg-cyan layuiadmin-badge">试卷</span>
        </div>
        <div class="layui-card-body layuiadmin-card-list">
          <p class="layuiadmin-big-font">{$paper_count}</p>
          <p>
            考试
            <span class="layuiadmin-span-color"> <i
                    class="layui-inline layui-icon layui-icon-flag"></i></span>
          </p>
        </div>
      </div>
    </div>
    <div class="layui-col-sm6 layui-col-md2">
      <div class="layui-card">
        <div class="layui-card-header">
          考试计划数量
          <span class="layui-badge layui-bg-green layuiadmin-badge">计划</span>
        </div>
        <div class="layui-card-body layuiadmin-card-list">

          <p class="layuiadmin-big-font">{$plan_count}</p>
          <p>
            考试
            <span class="layuiadmin-span-color"> <i
                    class="layui-inline layui-icon layui-icon-flag"></i></span>
          </p>
        </div>
      </div>
    </div>
    <div class="layui-col-sm6 layui-col-md2">
      <div class="layui-card">
        <div class="layui-card-header">
          学生用户人数
          <span class="layui-badge layui-bg-orange layuiadmin-badge">学生</span>
        </div>
        <div class="layui-card-body layuiadmin-card-list">

          <p class="layuiadmin-big-font">{$student_count}</p>
          <p>
            会员
            <span class="layuiadmin-span-color"> <i
                    class="layui-inline layui-icon layui-icon-user"></i></span>
          </p>
        </div>
      </div>
    </div>
    <div class="layui-col-sm6 layui-col-md2">
      <div class="layui-card">
        <div class="layui-card-header">
          后勤用户人数
          <span class="layui-badge layui-bg-orange layuiadmin-badge">后勤</span>
        </div>
        <div class="layui-card-body layuiadmin-card-list">

          <p class="layuiadmin-big-font">{$houqin_count}</p>
          <p>
            会员
            <span class="layuiadmin-span-color"> <i
                    class="layui-inline layui-icon layui-icon-user"></i></span>
          </p>
        </div>
      </div>
    </div>
    <div class="layui-col-sm6 layui-col-md2">
      <div class="layui-card">
        <div class="layui-card-header">
          参与考试总人数
          <span class="layui-badge layui-bg-cyan layuiadmin-badge">考试人数</span>
        </div>
        <div class="layui-card-body layuiadmin-card-list">

          <p class="layuiadmin-big-font">{$cankao_count}</p>
          <p>
            会员
            <span class="layuiadmin-span-color"> <i
                    class="layui-inline layui-icon layui-icon-user"></i></span>
          </p>
        </div>
      </div>
    </div>
    <div class="layui-col-sm12">
      <div class="layui-card">
        <div class="layui-card-header">
          <span id="fangwen">访问量(今天)</span>
          <div class="layui-btn-group layuiadmin-btn-group">
            <a href="javascript:;" class="layui-btn layui-btn-primary layui-btn-xs"
               onclick='get_tongji_data("today","今天")'>今天</a>
            <a href="javascript:;" class="layui-btn layui-btn-primary layui-btn-xs"
               onclick='get_tongji_data("yesterday","昨天")'>昨天</a>
            <a href="javascript:;" class="layui-btn layui-btn-primary layui-btn-xs"
               onclick='get_tongji_data("week","最近7天")'>最近7天</a>
            <a href="javascript:;" class="layui-btn layui-btn-primary layui-btn-xs"
               onclick='get_tongji_data("month","最近30天")'>最近30天</a>
            <a href="javascript:;" class="layui-btn layui-btn-primary layui-btn-xs"
               onclick='get_tongji_data("halfyear","最近半年")'>最近半年</a>
            <a href="javascript:;" class="layui-btn layui-btn-primary layui-btn-xs"
               onclick='get_tongji_data("year","最近一年")'>最近一年</a>
          </div>
        </div>
        <div class="layui-card-body">
          <div class="layui-row">
            <div class="layui-col-sm8" id="main" style="height:400px;">

            </div>
            <div class="layui-col-sm4" id="main2" style="height:400px;">

            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="layui-col-sm4">
      <div class="layui-card">
        <div class="layui-card-header">课件收藏排行榜</div>
        <div class="layui-card-body">
          <table class="layui-table layuiadmin-page-table" lay-skin="line">
            <thead>
            <tr>
              <th>课件名称</th>
              <th>收藏数</th>
            </tr>
            </thead>
            <tbody>
            {foreach $kejian as $v}
            <tr>
              <td>{$v.title}</td>
              <td style="text-align: center">{$v.save} <i class="layui-icon layui-icon-heart-fill " ></i></td>
            </tr>
            {/foreach}

            </tbody>
          </table>
        </div>
      </div>
    </div>
    <div class="layui-col-sm4">
      <div class="layui-card">
        <div class="layui-card-header">共享知识库点赞榜</div>
        <div class="layui-card-body">
          <table class="layui-table layuiadmin-page-table" lay-skin="line">
            <thead>
            <tr>
              <th>知识库名称</th>
              <th>点赞数</th>
            </tr>
            </thead>
            <tbody>
            {foreach $kejian as $v}
            <tr>
              <td>{$v.title}</td>
              <td style="text-align: center">{$v.save} <i class="layui-icon layui-icon-praise " ></i></td>
            </tr>
            {/foreach}
            </tbody>
          </table>
        </div>
      </div>
    </div>
    <div class="layui-col-sm4">
      <div class="layui-card">
        <div class="layui-card-header">宣传视频播放榜</div>
        <div class="layui-card-body">
          <table class="layui-table layuiadmin-page-table" lay-skin="line">
            <thead>
            <tr>
              <th>宣传视频名称</th>
              <th>播放量</th>
            </tr>
            </thead>
            <tbody>
            {foreach $kejian as $v}
            <tr>
              <td>{$v.title}</td>
              <td style="text-align: center">{$v.save} <i class="layui-icon layui-icon-play " ></i></td>
            </tr>
            {/foreach}
            </tbody>
          </table>
        </div>
      </div>
    </div>


  </div>
</div>
</div>

<script src="/static/admin/layui/layui.js"></script>
<script src="/static/js/jquery.min.js"></script>
<script src="/static/js/globals.js"></script>
<script>
  layui.config({
    base: '/static/admin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'sample']);
</script>


<script>
  $(function () {
    get_tongji_data("today",'今天');
  })
  var data;

  function get_tongji_data(type, desc) {
    $.get("/admin/index/getTongji?type=" + type, function (result) {
      data = result.msg;
      console.log(result)
      tongji();
      $("#fangwen").text('访问量（' + desc +'）');
    }, "json");
  }

  function tongji() {
    // 绘制图表。
    echarts.init(document.getElementById('main')).setOption({
      title: {
        text: '访客数据',
        subtext: '',
        x: 'center'
      },
      tooltip: {
        trigger: 'axis',
        axisPointer: {
          type: 'cross',
          label: {
            backgroundColor: '#6a7985'
          }
        }
      },
      // legend: {
      //     top: '10%',
      //     data: ['UUID']
      // },
      grid: {
        top: '20%',
        left: '1%',
        right: '1%',
        bottom: '1%',
        containLabel: true
      },
      xAxis: [
        {
          type: 'category',
          data: data.bar_name,
        }
      ],
      yAxis: [
        {
          type: 'value'
        }
      ],
      series: [
        {
          name: 'UUID',
          type: 'line',
          data: data.bar_ip_total
        },
      ]
    });
    // 绘制图表。
    echarts.init(document.getElementById('main2')).setOption({
      title: {
        text: '访问来源',
        subtext: '',
        x: 'center'
      },
      tooltip: {
        trigger: 'item',
        formatter: "{a} <br/>{b}: {c} ({d}%)"
      },
      // legend: {
      //     top: "10%",
      //     // orient: 'horizontal',
      //     x: 'center',
      //     data: data.pie_name
      // },
      series: [
        {
          name: '访问来源',
          type: 'pie',
          selectedMode: 'single',
          radius: [0, '60%'],
          center: ['50%', '50%'],
          label: {
            normal: {
              position: 'inner',
              top: '150px',
            }
          },
          labelLine: {
            normal: {
              show: false
            }
          },
          data: data.pie_data1
        },

      ]
    });
  }
</script>
</body>
</html>